package com.evan.review.architecture.components.navigation;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.evan.review.R;

/**
 * 详情Fragment
 */
public class DetailFragment extends Fragment {
    
    private int itemId;
    
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // 获取参数
        if (getArguments() != null) {
            DetailFragmentArgs args = DetailFragmentArgs.fromBundle(getArguments());
            itemId = args.getItemId();
        }
    }
    
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_detail, container, false);
    }
    
    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        
        // 显示项目ID
        TextView tvItemId = view.findViewById(R.id.tv_item_id);
        tvItemId.setText("项目ID: " + itemId);
        
        // 显示详情内容
        TextView tvItemDetail = view.findViewById(R.id.tv_item_detail);
        tvItemDetail.setText("这是项目 " + itemId + " 的详细信息。\n\n" +
                "Navigation组件使得在Fragment之间传递参数变得简单安全。\n\n" +
                "使用Safe Args可以确保类型安全，避免运行时错误。");
    }
} 